home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / CodeWarrior Lite / Metrowerks C⁄C++ Lite / Headers / Universal Headers 2.0.1f / Lists.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-22  |  11.5 KB  |  316 lines  |  [TEXT/MMCC]

  1. /*
  2.      File:        Lists.h
  3.  
  4.      Contains:    List Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __LISTS__
  21. #define __LISTS__
  22.  
  23.  
  24. #ifndef __TYPES__
  25. #include <Types.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __CONTROLS__
  30. #include <Controls.h>
  31. #endif
  32. /*    #include <Quickdraw.h>                                        */
  33. /*        #include <MixedMode.h>                                    */
  34. /*        #include <QuickdrawText.h>                                */
  35. /*    #include <Menus.h>                                            */
  36. /*        #include <Memory.h>                                        */
  37.  
  38. #ifndef __MEMORY__
  39. #include <Memory.h>
  40. #endif
  41.  
  42. #ifdef __cplusplus
  43. extern "C" {
  44. #endif
  45.  
  46. #if PRAGMA_ALIGN_SUPPORTED
  47. #pragma options align=mac68k
  48. #endif
  49.  
  50. #if PRAGMA_IMPORT_SUPPORTED
  51. #pragma import on
  52. #endif
  53.  
  54. #ifndef STRICT_LISTS
  55. #define STRICT_LISTS 0
  56. #endif
  57. #if !STRICT_LISTS
  58.  
  59. enum {
  60.     lDoVAutoscroll                = 2,
  61.     lDoHAutoscroll                = 1,
  62.     lOnlyOne                    = -128,
  63.     lExtendDrag                    = 64,
  64.     lNoDisjoint                    = 32,
  65.     lNoExtend                    = 16,
  66.     lNoRect                        = 8,
  67.     lUseSense                    = 4,
  68.     lNoNilHilite                = 2
  69. };
  70.  
  71. #endif
  72.  
  73. enum {
  74.     lInitMsg                    = 0,
  75.     lDrawMsg                    = 1,
  76.     lHiliteMsg                    = 2,
  77.     lCloseMsg                    = 3
  78. };
  79.  
  80. #if STRICT_LISTS
  81. typedef struct OpaqueListRef *ListRef;
  82.  
  83. typedef ListRef ListHandle;
  84.  
  85. #else
  86. typedef struct ListRec ListRec, *ListPtr, **ListHandle;
  87.  
  88. typedef ListHandle ListRef;
  89.  
  90. #endif
  91. typedef Point Cell;
  92.  
  93. typedef Rect ListBounds;
  94.  
  95. typedef char DataArray[32001];
  96.  
  97. typedef char *DataPtr, **DataHandle;
  98.  
  99. typedef pascal short (*ListSearchProcPtr)(Ptr aPtr, Ptr bPtr, short aLen, short bLen);
  100. /*
  101.         ListClickLoopProcPtr uses register based parameters on the 68k and cannot
  102.         be written in or called from a high-level language without the help of
  103.         mixed mode or assembly glue.
  104.  
  105.             typedef pascal Boolean (*ListClickLoopProcPtr)(void);
  106.  
  107.         In:
  108.          =>                 .?
  109.         Out:
  110.          <= return value    D0.B
  111. */
  112.  
  113. #if GENERATINGCFM
  114. typedef UniversalProcPtr ListSearchUPP;
  115. typedef UniversalProcPtr ListClickLoopUPP;
  116. #else
  117. typedef ListSearchProcPtr ListSearchUPP;
  118. typedef Register68kProcPtr ListClickLoopUPP;
  119. #endif
  120.  
  121. #if !STRICT_LISTS
  122. struct ListRec {
  123.     Rect                            rView;
  124.     GrafPtr                            port;
  125.     Point                            indent;
  126.     Point                            cellSize;
  127.     ListBounds                        visible;
  128.     ControlRef                        vScroll;
  129.     ControlRef                        hScroll;
  130.     SInt8                            selFlags;
  131.     Boolean                            lActive;
  132.     SInt8                            lReserved;
  133.     SInt8                            listFlags;
  134.     long                            clikTime;
  135.     Point                            clikLoc;
  136.     Point                            mouseLoc;
  137.     ListClickLoopUPP                lClickLoop;
  138.     Cell                            lastClick;
  139.     long                            refCon;
  140.     Handle                            listDefProc;
  141.     Handle                            userHandle;
  142.     ListBounds                        dataBounds;
  143.     DataHandle                        cells;
  144.     short                            maxIndex;
  145.     short                            cellArray[1];
  146. };
  147. #endif
  148. typedef pascal void (*ListDefProcPtr)(short lMessage, Boolean lSelect, Rect *lRect, Cell lCell, short lDataOffset, short lDataLen, ListRef lHandle);
  149. typedef pascal void (*ListCellDrawProcPtr)(short lMessage, Boolean lSelect, Rect *lRect, Cell lCell, void *dataPtr, short lDataLen, ListRef lHandle);
  150.  
  151. #if GENERATINGCFM
  152. typedef UniversalProcPtr ListDefUPP;
  153. typedef UniversalProcPtr ListCellDrawUPP;
  154. #else
  155. typedef ListDefProcPtr ListDefUPP;
  156. typedef ListCellDrawProcPtr ListCellDrawUPP;
  157. #endif
  158.  
  159. enum {
  160.     uppListSearchProcInfo = kPascalStackBased
  161.          | RESULT_SIZE(SIZE_CODE(sizeof(short)))
  162.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Ptr)))
  163.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr)))
  164.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short)))
  165.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short))),
  166.     uppListClickLoopProcInfo = kRegisterBased
  167.          | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
  168.          | REGISTER_RESULT_LOCATION(kRegisterD0),
  169.     uppListDefProcInfo = kPascalStackBased
  170.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  171.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Boolean)))
  172.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Rect*)))
  173.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(Cell)))
  174.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(short)))
  175.          | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(short)))
  176.          | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(ListRef))),
  177.     uppListCellDrawProcInfo = kPascalStackBased
  178.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  179.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Boolean)))
  180.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Rect*)))
  181.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(Cell)))
  182.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(void*)))
  183.          | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(short)))
  184.          | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(ListRef)))
  185. };
  186.  
  187. #if GENERATINGCFM
  188. #define NewListSearchProc(userRoutine)        \
  189.         (ListSearchUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppListSearchProcInfo, GetCurrentArchitecture())
  190. #define NewListClickLoopProc(userRoutine)        \
  191.         (ListClickLoopUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppListClickLoopProcInfo, GetCurrentArchitecture())
  192. #define NewListDefProc(userRoutine)        \
  193.         (ListDefUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppListDefProcInfo, GetCurrentArchitecture())
  194. #define NewListCellDrawProc(userRoutine)        \
  195.         (ListCellDrawUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppListCellDrawProcInfo, GetCurrentArchitecture())
  196. #else
  197. #define NewListSearchProc(userRoutine)        \
  198.         ((ListSearchUPP) (userRoutine))
  199. #define NewListClickLoopProc(userRoutine)        \
  200.         ((ListClickLoopUPP) (userRoutine))
  201. #define NewListDefProc(userRoutine)        \
  202.         ((ListDefUPP) (userRoutine))
  203. #define NewListCellDrawProc(userRoutine)        \
  204.         ((ListCellDrawUPP) (userRoutine))
  205. #endif
  206.  
  207. #if GENERATINGCFM
  208. #define CallListSearchProc(userRoutine, aPtr, bPtr, aLen, bLen)        \
  209.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppListSearchProcInfo, (aPtr), (bPtr), (aLen), (bLen))
  210. #define CallListClickLoopProc(userRoutine)        \
  211.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppListClickLoopProcInfo)
  212. #define CallListDefProc(userRoutine, lMessage, lSelect, lRect, lCell, lDataOffset, lDataLen, lHandle)        \
  213.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppListDefProcInfo, (lMessage), (lSelect), (lRect), (lCell), (lDataOffset), (lDataLen), (lHandle))
  214. #define CallListCellDrawProc(userRoutine, lMessage, lSelect, lRect, lCell, dataPtr, lDataLen, lHandle)        \
  215.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppListCellDrawProcInfo, (lMessage), (lSelect), (lRect), (lCell), (dataPtr), (lDataLen), (lHandle))
  216. #else
  217. #define CallListSearchProc(userRoutine, aPtr, bPtr, aLen, bLen)        \
  218.         (*(userRoutine))((aPtr), (bPtr), (aLen), (bLen))
  219. /* (*ListClickLoopProcPtr) cannot be called from a high-level language without the Mixed Mode Manager */
  220. #define CallListDefProc(userRoutine, lMessage, lSelect, lRect, lCell, lDataOffset, lDataLen, lHandle)        \
  221.         (*(userRoutine))((lMessage), (lSelect), (lRect), (lCell), (lDataOffset), (lDataLen), (lHandle))
  222. #define CallListCellDrawProc(userRoutine, lMessage, lSelect, lRect, lCell, dataPtr, lDataLen, lHandle)        \
  223.         (*(userRoutine))((lMessage), (lSelect), (lRect), (lCell), (dataPtr), (lDataLen), (lHandle))
  224. #endif
  225.  
  226. extern pascal ListRef LNew(const Rect *rView, const ListBounds *dataBounds, Point cSize, short theProc, WindowRef theWindow, Boolean drawIt, Boolean hasGrow, Boolean scrollHoriz, Boolean scrollVert)
  227.  THREEWORDINLINE(0x3F3C, 0x0044, 0xA9E7);
  228. extern pascal void LDispose(ListRef lHandle)
  229.  THREEWORDINLINE(0x3F3C, 0x0028, 0xA9E7);
  230. extern pascal short LAddColumn(short count, short colNum, ListRef lHandle)
  231.  THREEWORDINLINE(0x3F3C, 0x0004, 0xA9E7);
  232. extern pascal short LAddRow(short count, short rowNum, ListRef lHandle)
  233.  THREEWORDINLINE(0x3F3C, 0x0008, 0xA9E7);
  234. extern pascal void LDelColumn(short count, short colNum, ListRef lHandle)
  235.  THREEWORDINLINE(0x3F3C, 0x0020, 0xA9E7);
  236. extern pascal void LDelRow(short count, short rowNum, ListRef lHandle)
  237.  THREEWORDINLINE(0x3F3C, 0x0024, 0xA9E7);
  238. extern pascal Boolean LGetSelect(Boolean next, Cell *theCell, ListRef lHandle)
  239.  THREEWORDINLINE(0x3F3C, 0x003C, 0xA9E7);
  240. extern pascal Cell LLastClick(ListRef lHandle)
  241.  THREEWORDINLINE(0x3F3C, 0x0040, 0xA9E7);
  242. extern pascal Boolean LNextCell(Boolean hNext, Boolean vNext, Cell *theCell, ListRef lHandle)
  243.  THREEWORDINLINE(0x3F3C, 0x0048, 0xA9E7);
  244. extern pascal Boolean LSearch(const void *dataPtr, short dataLen, ListSearchUPP searchProc, Cell *theCell, ListRef lHandle)
  245.  THREEWORDINLINE(0x3F3C, 0x0054, 0xA9E7);
  246. extern pascal void LSize(short listWidth, short listHeight, ListRef lHandle)
  247.  THREEWORDINLINE(0x3F3C, 0x0060, 0xA9E7);
  248. extern pascal void LSetDrawingMode(Boolean drawIt, ListRef lHandle)
  249.  THREEWORDINLINE(0x3F3C, 0x002C, 0xA9E7);
  250. extern pascal void LScroll(short dCols, short dRows, ListRef lHandle)
  251.  THREEWORDINLINE(0x3F3C, 0x0050, 0xA9E7);
  252. extern pascal void LAutoScroll(ListRef lHandle)
  253.  THREEWORDINLINE(0x3F3C, 0x0010, 0xA9E7);
  254. extern pascal void LUpdate(RgnHandle theRgn, ListRef lHandle)
  255.  THREEWORDINLINE(0x3F3C, 0x0064, 0xA9E7);
  256. extern pascal void LActivate(Boolean act, ListRef lHandle)
  257.  TWOWORDINLINE(0x4267, 0xA9E7);
  258. extern pascal void LCellSize(Point cSize, ListRef lHandle)
  259.  THREEWORDINLINE(0x3F3C, 0x0014, 0xA9E7);
  260. extern pascal Boolean LClick(Point pt, short modifiers, ListRef lHandle)
  261.  THREEWORDINLINE(0x3F3C, 0x0018, 0xA9E7);
  262. extern pascal void LAddToCell(const void *dataPtr, short dataLen, Cell theCell, ListRef lHandle)
  263.  THREEWORDINLINE(0x3F3C, 0x000C, 0xA9E7);
  264. extern pascal void LClrCell(Cell theCell, ListRef lHandle)
  265.  THREEWORDINLINE(0x3F3C, 0x001C, 0xA9E7);
  266. extern pascal void LGetCell(void *dataPtr, short *dataLen, Cell theCell, ListRef lHandle)
  267.  THREEWORDINLINE(0x3F3C, 0x0038, 0xA9E7);
  268. extern pascal void LRect(Rect *cellRect, Cell theCell, ListRef lHandle)
  269.  THREEWORDINLINE(0x3F3C, 0x004C, 0xA9E7);
  270. extern pascal void LSetCell(const void *dataPtr, short dataLen, Cell theCell, ListRef lHandle)
  271.  THREEWORDINLINE(0x3F3C, 0x0058, 0xA9E7);
  272. extern pascal void LSetSelect(Boolean setIt, Cell theCell, ListRef lHandle)
  273.  THREEWORDINLINE(0x3F3C, 0x005C, 0xA9E7);
  274. extern pascal void LDraw(Cell theCell, ListRef lHandle)
  275.  THREEWORDINLINE(0x3F3C, 0x0030, 0xA9E7);
  276. #if !STRICT_LISTS
  277. extern pascal void LGetCellDataLocation(short *offset, short *len, Cell theCell, ListRef lHandle)
  278.  THREEWORDINLINE(0x3F3C, 0x0034, 0xA9E7);
  279. #endif
  280. #if CGLUESUPPORTED
  281. extern void laddtocell(Ptr dataPtr, short dataLen, Cell *theCell, ListRef lHandle);
  282. extern void lclrcell(Cell *theCell, ListRef lHandle);
  283. extern void lgetcelldatalocation(short *offset, short *len, Cell *theCell, ListRef lHandle);
  284. extern void lgetcell(Ptr dataPtr, short *dataLen, Cell *theCell, ListRef lHandle);
  285. extern ListRef lnew(Rect *rView, ListBounds *dataBounds, Point *cSize, short theProc, WindowRef theWindow, Boolean drawIt, Boolean hasGrow, Boolean scrollHoriz, Boolean scrollVert);
  286. extern void lrect(Rect *cellRect, Cell *theCell, ListRef lHandle);
  287. extern void lsetcell(Ptr dataPtr, short dataLen, Cell *theCell, ListRef lHandle);
  288. extern void lsetselect(Boolean setIt, Cell *theCell, ListRef lHandle);
  289. extern void ldraw(Cell *theCell, ListRef lHandle);
  290. extern Boolean lclick(Point *pt, short modifiers, ListRef lHandle);
  291. extern void lcellsize(Point *cSize, ListRef lHandle);
  292. #endif
  293. #if OLDROUTINENAMES
  294. #define LDoDraw(drawIt, lHandle) LSetDrawingMode(drawIt, lHandle)
  295. #define LFind(offset, len, theCell, lHandle)  \
  296.     LGetCellDataLocation(offset, len, theCell, lHandle)
  297. #if CGLUESUPPORTED
  298. #define lfind(offset, len, theCell, lHandle)  \
  299.     lgetcelldatalocation(offset, len, theCell, lHandle)
  300. #endif
  301. #endif
  302.  
  303. #if PRAGMA_IMPORT_SUPPORTED
  304. #pragma import off
  305. #endif
  306.  
  307. #if PRAGMA_ALIGN_SUPPORTED
  308. #pragma options align=reset
  309. #endif
  310.  
  311. #ifdef __cplusplus
  312. }
  313. #endif
  314.  
  315. #endif /* __LISTS__ */
  316.